/*
 * $Id$
 */
package py.firefly.util;

import com.jolbox.bonecp.BoneCPDataSource;

import javax.sql.DataSource;

/**
 *
 * @author py
 */
public class DataSourceFactory {

	public static DataSource newDataSource(final Database db) {
		final BoneCPDataSource bds = new BoneCPDataSource();
		try {
			Class.forName(db.getDriver());
		} catch (ClassNotFoundException ex) {
			throw new RuntimeException(ex);
		}
		bds.setJdbcUrl(db.getJdbcUrl());
		bds.setUsername(db.getUsername());
		bds.setPassword(db.getPassword());
		return bds;
	}
}
